home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 25
/
Cream of the Crop 25.iso
/
bbs
/
fido10as.zip
/
FIDOADDR.DOC
< prev
next >
Wrap
Text File
|
1997-04-08
|
8KB
|
174 lines
fido_address
=============================================================================
This class implements a non-view parser for manipulating FidoNet(tm)
style network addresses. It is fully compliant with the FTSC-001
standard and also supports full 4D addressing with zones and points.
As an added bonus, this class supports 5D addressing with domains as
well.
The class is quite intelligent as is able to recognize several valid
addresses with otherwise missing parts. For example, all of the
addresses listed below will be parsed correctly (they are valid):
1:383/47.0@fidonet.org
1:383/47@fidonet.org
383/47.0@fidonet.org
383/47@fidonet.org
1:383/47.0
1:383/47
383/47.0
383/47
47.0
47
As you can see, only one of the fields must be present in order for
an address specification to be considered valid. This is the node
numbers. The general format used by FidoNet-type technology is as
follows:
zone:net/node.point@domain
Any of the fields can be omitted except for the node designation.
This class uses integers to represent all the numbers, so there will
be no problem with high zone designations (some software incorrectly
limits the zone numbers to less than 256).
FIDO_ADDRESS::FIDO_ADDRESS
-------------------------------------------------------------------------
Summary Various constructors for the object
Syntax fido_address();
fido_address(int zone, int node, int net, int point);
fido_address(int zone, int node, int net, int point,
const char *domain);
fido_address(const fido_address &addr);
fido_address(const char *ascii_address);
Remarks These constructors allow several different ways of
initializing the object. The first and simplest one will
only set the internal fields to 0 (note that this will
form an invalid address). The second and third ones will
construct an object with values supplied by the user. The
fourth version is the copy constructor which will create
a fido_addres object from another already existing one.
The last constructor is probably the most interesting as
this is the one that actually parses an address stored in
a string. The string must contain the address only, no
whitespace or extraneous characters are permissible. As
indicated in the introductory notes, all legal formats will
be recognized and parsed by this routine. Fields that do
not exist in the address will be set to 0.
Return n/a
FIDO_ADDRESS::SET_ZONE, SET_NET, SET_NODE, SET_POINT, SET_DOMAIN
-------------------------------------------------------------------------
Summary Set manually the different address portions
Syntax void set_zone(int zone);
void set_net(int net);
void set_node(int node);
void set_point(int point);
void set_domain(const char *domain);
Remarks These routines are fairly intuitive and should be used
when there is a need to modify the address values stored
in the object. No error-checking is performed. You might
want to use these after parsing an address which has one
or more parts missing. Since all missing parts will be
set to 0 by the parser, they are readily identifiable and
can be modified as necessary.
Return Nothing
FIDO_ADDRESS::SPLIT
-------------------------------------------------------------------------
Summary Parse an address from a string
Syntax void split(const char *address);
Remarks This routine is actually used by the constructor which
parses a string with the address. Same restrictions apply
here too. Use this routine when you want to dynamically
change the object contents with another string address
(thereby eliminating the need for additional objects).
Return Nothing
FIDO_ADDRESS::OPERATOR=
-------------------------------------------------------------------------
Summary Assigns one object to another
Syntax fido_address& operator=(const fido_address& addr);
Remarks The assignment operator is very intuitive and it does
exactly what you would expect it to do. It takes the
'addr' object and copies its values to the rvalue object
which invoked the operator.
Return Reference to the calling object
FIDO_ADDRESS::ZONE, NET, NODE, POINT, DOMAIN
-------------------------------------------------------------------------
Summary Return the values of address parts
Syntax int zone() const;
int net() const;
int node() const;
int point() const;
char* domain(char *buf) const;
Remarks These accessors can be used to retrieve any single part
of the address stored in the object. Special note regarding
the domain() method is that the 'buf' parameter is
required as this is where the domain string will be copied
to. It should be big enough to accomodate it (a reasonable
limit of 256 characters should be adequate).
Return Each function returns the respective part of the address.
domain() returns the pointer supplied to it.
FIDO_ADDRESS::MERGE, MERGE2D, MERGE3D, MERGE4D, MERGE5D
-------------------------------------------------------------------------
Summary Create string representation of the address
Syntax char* merge(char *buf) const;
char* merge2d(char *buf) const;
char* merge3d(char *buf) const;
char* merge4d(char *buf) const;
char* merge5d(char *buf) const;
Remarks These functions will merge the address information into
a valid FidoNet-style string. They all expect 'buf' which
is supplied by the user to be large enough to accomodate
the resulting string. No error-checking is performed. A
buffer size of 256 characters should be adequate for most
needs. The merge() method will create a string with the
maximum number of available parts (all portions which are
0 will be omitted, except for the node). The merge2d()
routine will always produce a net/node combination
regardless of the values. The merge3d() function will
always produce the zone:net/node string regardless of the
actual values. merge4d() will produce the full and most
common format of zone:net/node.point regardless of the
individual values. Finally, merge5d() will produce the
full 5D address if a domain name is specified, otherwise,
it will return the same result as merge4d(). This is the
preferred method to use.
Return Pointer to the supplied buffer